// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Security;

public sealed partial class Hint
{
	/// <summary>
	/// <para>
	/// A single key-value pair to match against the labels section
	/// of a profile. A profile is considered matching if it matches
	/// at least one of the strings.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("labels")]
	public IDictionary<string, Union<string, ICollection<string>>>? Labels { get; set; }

	/// <summary>
	/// <para>
	/// A list of Profile UIDs to match against.
	/// </para>
	/// </summary>
	[JsonInclude, JsonPropertyName("uids")]
	public ICollection<string>? Uids { get; set; }
}

public sealed partial class HintDescriptor : SerializableDescriptor<HintDescriptor>
{
	internal HintDescriptor(Action<HintDescriptor> configure) => configure.Invoke(this);

	public HintDescriptor() : base()
	{
	}

	private IDictionary<string, Union<string, ICollection<string>>>? LabelsValue { get; set; }
	private ICollection<string>? UidsValue { get; set; }

	/// <summary>
	/// <para>
	/// A single key-value pair to match against the labels section
	/// of a profile. A profile is considered matching if it matches
	/// at least one of the strings.
	/// </para>
	/// </summary>
	public HintDescriptor Labels(Func<FluentDictionary<string, Union<string, ICollection<string>>>, FluentDictionary<string, Union<string, ICollection<string>>>> selector)
	{
		LabelsValue = selector?.Invoke(new FluentDictionary<string, Union<string, ICollection<string>>>());
		return Self;
	}

	/// <summary>
	/// <para>
	/// A list of Profile UIDs to match against.
	/// </para>
	/// </summary>
	public HintDescriptor Uids(ICollection<string>? uids)
	{
		UidsValue = uids;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (LabelsValue is not null)
		{
			writer.WritePropertyName("labels");
			JsonSerializer.Serialize(writer, LabelsValue, options);
		}

		if (UidsValue is not null)
		{
			writer.WritePropertyName("uids");
			JsonSerializer.Serialize(writer, UidsValue, options);
		}

		writer.WriteEndObject();
	}
}